from django.contrib import admin
from django.http import HttpResponse
from django.urls import path, include
from jewelry import views
from django.conf import settings
from django.conf.urls.static import static
from django.contrib.auth.views import LogoutView

urlpatterns = [
    path('admin/logout/', LogoutView.as_view(next_page='/admin/'), name='admin_logout'),
    path('logout/', LogoutView.as_view(next_page='/'), name='logout'),  # 后端注销登录
    path('admin/', admin.site.urls),
    path('ckeditor/', include('ckeditor_uploader.urls')),  # 富文本编辑器V4，内置路由ckeditor_uploader.urls
    # path('ckeditor5/', include('django_ckeditor_5.urls')),   # 富文本编辑器V5

    path('api/', include('jewelry.urls', namespace='jewelry')),  # 首饰珠宝商城(微信小程序客户端)
    path('acc/', include('account.urls', namespace='account')),  # 跨应用跳转必须声明   # (后端系统设置)
    path('ecom/', include('ecom.urls.urls', namespace='ecom')),   # 电商管理

    path('', views.index, name='index'),  # 首页

    # 捕获常见的隐形请求
    path('favicon.ico', lambda r: HttpResponse(status=204), name='favicon'),

]

# 开发环境添加静态文件路由:映射媒体文件路径:如/media/...图片; /static/...
if settings.DEBUG:
    urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
    urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
